package com.wly.datapool
{
	import com.wly.event.EventCodes;
	import com.wly.event.EventManager;

	public class MainPlayer
	{
		private var _lifeNum:int;
		private var _score:int;
		private var _rmb:int;
		private var _maxScore:int;
		
		public function MainPlayer()
		{
			_lifeNum = 4;
		}
		
		public function subOneLife():void
		{
			_lifeNum--;
			
			EventManager.getInstance().dispatchEvent(EventCodes.EVENT_PLAYER_LIFE_UPDATE, null);
		}
		
		public function addLift(val:int):void
		{
			_lifeNum += val;
			EventManager.getInstance().dispatchEvent(EventCodes.EVENT_PLAYER_LIFE_UPDATE, null);
		}
		
		public function get lifeNum():int
		{
			return _lifeNum;
		}
		
		public function get score():int
		{
			return _score;
		}
		
		public function addScore(val:int):void
		{
			_score += val;
			if(_score > _maxScore)
			{
				maxScore = _score;
			}
			EventManager.getInstance().dispatchEvent(EventCodes.EVENT_PLAYER_SCORE_UPDATE, _score);
		}
		
		public function addRmb(val:int):void
		{
			_rmb += val;
			EventManager.getInstance().dispatchEvent(EventCodes.EVENT_PLAYER_RMB_UPDATE, _rmb);
		}
		
		public function get rmb():int
		{
			return _rmb;
		}
		
		public function get maxScore():int
		{
			return _maxScore;
		}
		
		public function set maxScore(val:int):void
		{
			_maxScore = val;
			EventManager.getInstance().dispatchEvent(EventCodes.EVENT_PLAYER_MAXSCORE_UPDATE, _maxScore);
		}
	}
}